package devkit.commando {
	
	import mx.collections.ArrayCollection;
	import mx.rpc.events.FaultEvent;
	
	/**
	 * Class used to maintain a list of the commands that has failed while executing.
	 * @author Francois Dempers
	 */
	public class ErrorChain extends ArrayCollection {
		
		/** The function to invoke should any error occur. */
		public var handler:Function;
		
		/**
		 * Adds a error to the list of errors.
		 * @param command The command which has failed
		 * @param fault The error returned by a command.
		 */
		public function logError(command:CommandBase, fault:FaultEvent):void {
			
			addItem(fault);
			
			if(handler != null) {
				handler.call(this, fault);
			}
		}
	}
}